<!--
 Licensed under the Apache License, Version 2.0 (the "License");
 you may not use this file except in compliance with the License.
 You may obtain a copy of the License at

 http://www.apache.org/licenses/LICENSE-2.0

 Unless required by applicable law or agreed to in writing, software
 distributed under the License is distributed on an "AS IS" BASIS,
 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 See the License for the specific language governing permissions and
 limitations under the License.
-->
<div class="create-route" fileDragDrop (fileDragDropFileAccepted)="fileAccepted($event)"
     (fileDragDropFileRejected)="fileRejected($event)"
     (fileDragDropDragOver)="fileDetected($event)" (fileDragDropDragLeave)="fileLeft($event)"
     [maxFileSize]="maxFileSize" >
    <div class="file-types-list">
        <div class="file-types-list-item">
            <input type="radio" id="useCert" name="file-type" [checked]="true"
                   (change)="useCertificates(true)">
            <label class="radio-label" for="useCert"><h3>Certificates</h3></label>
            <div class="description"><p>Required here are certificate and private key
                files.</p></div>
        </div>
        <div class="file-types-list-item">
            <input type="radio" id="noCert" name="file-type"
                   (change)="useCertificates(false)">
            <label class="radio-label" for="noCert"><h3>ID and Secret</h3></label>
            <div class="description"><p>These can be created when accessing a business network.</p></div>
        </div>
    </div>
</div>
<form #credentialsForm="ngForm" id="credentials-form">
    <div *ngIf="useCerts" class="noCerts">
        <table class="no-shadow">
            <colgroup>
                <col span="1" style="width: 20%;">
                <col span="1" style="width: 80%;">
            </colgroup>
            <tr>
                <th>
                    <label for="publicKey"><h3>Certificate</h3></label>
                    <file-importer id="publicKeyImporter" (fileAccepted)="fileAccepted($event, 'public')"
                                   (fileRejected)="fileRejected($event)" [expandInput]="expandInput"
                                   [maxFileSize]="maxFileSize"
                                   [ngClass]="{'expandFile': expandInput}"
                                   [svgName]="'#icon-CTO_JS_Upload'"></file-importer>
                </th>
                <td>
            <textarea required name="addedPublicCertificate" id="publicKey" rows="6"
                      placeholder="Paste your certificate here..."
                      [(ngModel)]="addedPublicCertificate"></textarea>
                </td>
            </tr>
            <tr>

                <th>
                    <label for="privateKey"><h3>Private Key</h3></label>
                    <file-importer id="privateKeyImporter" (fileAccepted)="fileAccepted($event, 'private')"
                                   (fileRejected)="fileRejected($event)" [expandInput]="expandInput"
                                   [maxFileSize]="maxFileSize"
                                   [ngClass]="{'expandFile': expandInput}"
                                   [svgName]="'#icon-CTO_JS_Upload'"></file-importer>
                </th>
                <td>
                <textarea required name="addedPrivateCertificate" id="privateKey" rows="6"
                          placeholder="Paste your private key here..."
                          [(ngModel)]="addedPrivateCertificate"></textarea>
                </td>
            </tr>
            <tr>
                <th>
                    <label for="name"><h3>The user id</h3></label>
                </th>
                <td>
                    <input required type="text" [(ngModel)]="userId" id="name" name="userId" autocomplete="off">
                </td>
            </tr>
        </table>
    </div>
    <div *ngIf="!useCerts" class="noCerts">
        <p>An Enrollment ID and Secret must be created by someone who already has access to the Business Network
            you are connecting to.</p>
        <table class="no-shadow">
            <colgroup>
                <col span="1" style="width: 20%;">
                <col span="1" style="width: 80%;">
            </colgroup>
            <tr>
                <th>
                    <label for="userId"><h3>Enrollment ID</h3></label>
                </th>
                <td>
                    <input required type="text" [(ngModel)]="userId" id="userId" name="userId" autocomplete="off">
                </td>
            </tr>
            <tr>
                <th>
                    <label for="userSecret"><h3>Enrollment Secret</h3></label>
                </th>
                <td>
                    <input required type="password" [(ngModel)]="userSecret" id="userSecret" name="userSecret"
                           autocomplete="off">
                </td>
            </tr>
        </table>
    </div>
</form>



